package com.press.services;

import com.press.bean.OptionBean;
import com.press.mapper.InitOptionMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by haocongshun on 2016/10/2.
 */
@Service("initService")
public class InitService {
    @Resource(name = "initOptionMapper")
    private InitOptionMapper initOptionMapper;

    public InitOptionMapper getInitOptionMapper() {
        return initOptionMapper;
    }

    public void setInitOptionMapper(InitOptionMapper initOptionMapper) {
        this.initOptionMapper = initOptionMapper;
    }

    public Map<String ,String > init(){
        List<OptionBean> listOption = initOptionMapper.getOption();
        Map<String ,String > mapOption = new HashMap<>();
        for (OptionBean optionBean : listOption){
            mapOption.put(optionBean.getOption_key(),(optionBean.getOption_value()==null?"":optionBean.getOption_value()));
        }
        return mapOption;
    }
}
